package com.atde._01_principle.inversion.improve;


/**
 * @Author: Del
 * @CreateTime: 2025-04-12
 * @Description: 依赖倒置演示
 * @Version: 1.0
 */
public class DependecyImproveInversion {
}

// 设计一个抽象接口
interface IReceiver {
    String getInfo();
}

// 让不同的接收者实现接口
class Email implements IReceiver {
    public String getInfo() {
        return "电子邮件信息: hello,world";
    }
}

// 增加短信的接口 不会影响原来的代码
class Message implements IReceiver {
    public String getInfo() {
        return "短信信息: hello,world";
    }
}

// 让 Person 依赖 接口，而不是依赖具体类 Email
class Person01 {
    public void receive(IReceiver receiver) {
        System.out.println(receiver.getInfo());
    }
}
